package com.example.cyk.config.response;

/**
 * 统一约定状态码及状态信息
 */
public enum CodeMsg {
    //基本状态
    SUCCESS                              (1000, "操作成功"),
    FAIL                                 (1100, "操作失败"),
    //用户相关状态
    FAIL_NULL_USERNAME_OR_PASSWORD       (1200, "用户名或密码为空"),
    FAIL_ERROR_USERNAME_OR_PASSWORD      (1201, "用户名或密码错误"),
    FAIL_NULL_USERNAME                   (1202, "用户名为空"),
    FAIL_NULL_NAME_OR_NICK_OR_PASSWORD   (1203, "用户名或昵称或密码为空"),
    FAIL_EXISTS_USERNAME                 (1204, "用户名已存在"),
    FAIL_NULL_USERID                     (1205, "用户 Id 为空"),
    FAIL_NOT_EXISTS_USERINFO             (1206, "该用户信息不存在"),
    //文章相关状态
    FAIL_NULL_CURPAGE_PAGESIZE           (1300, "分页数据为空"),
    FAIL_ERROR_CURPAGE_PAGESIZE          (1301, "分页数据非法"),
    FAIL_NULL_BOARD_CURPAGE_PAGESIZE           (1302, "板块分页数据为空"),
    FAIL_NULL_BOARD                      (1303, "板块名为空"),
    FAIL_NULL_ARTICLE                    (1304, "文章信息不完整"),
    NORMAL_NULL_ARTICLE                  (1305, "当前没有文章，快来发布吧~"),
    //其他异常
    ERROR_PARAM                          (10000, "未通过前端页面传入非法参数!"),
    //服务错误
    ERROR_SERVICE (11000, "服务器错误")

    ;

    private Integer code;
    private String msg;

    CodeMsg(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "code: " + code + ", msg: " + msg + ".";
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
